package com.bai.lease.web.admin.controller.apartment;


import com.bai.lease.common.result.Result;
import com.bai.lease.model.untils.OSSUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


@Tag(name = "文件管理")
@RequestMapping("/admin/file")
@RestController
public class FileUploadController {

    @Autowired
    private OSSUtils ossUtils;

    @Operation(summary = "阿里云文件上传")
    @PostMapping("upload")
    public Result<String> upload(@RequestParam MultipartFile file) {
        try {
            return Result.ok(ossUtils.upload(file));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }


}
